package com.ee.chat.cps.admin.controller.usermanage;

import com.ee.chat.common.bean.Result;
import com.ee.chat.common.entity.Channel;
import com.ee.chat.cps.admin.service.IChannelService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("channel")
public class ChannelController {
    private Logger log = LoggerFactory.getLogger(ChannelController.class);

    @Resource
    IChannelService channelService;

    /**
     * 编辑渠道商信息
     * @Author AppiJ
     * @Date 2020/3/28 16:44
     * @param
     * @return
     */
    @RequestMapping("toEdit")
    public Result toEdit(HttpServletRequest request, @RequestParam Integer id){
        try{
            return channelService.toEdit(request, id);
        }catch (Exception e){
            log.error("【编辑渠道商信息错误】", e);
        }
        return Result.returnFailure();
    }

    /**
     * 保存渠道商信息
     * @Author AppiJ
     * @Date 2020/3/29 12:13
     * @param
     * @return
     */
    @RequestMapping("edit")
    public Result edit(HttpServletRequest request, Channel channel){
        try{
            return channelService.edit(request, channel);
        }catch (Exception e){
            log.error("【保存渠道商信息错误】", e);
        }
        return Result.returnFailure();
    }

}
